package com.ssextjs.engine;

import java.io.File;
import java.io.IOException;

import javax.servlet.http.HttpServlet;

import freemarker.template.Configuration;
import freemarker.template.DefaultObjectWrapper;

public class ConfiguraionImpl {
	public static Configuration cfg;
	
	public static void initCfg(HttpServlet serv) {
		if (cfg==null) {
			cfg = new Configuration();
	        try {
				cfg.setDirectoryForTemplateLoading(new File(serv.getServletContext().getRealPath("/")+"/WEB-INF/ssextjs/templates/"));
				cfg.setObjectWrapper(new DefaultObjectWrapper());  
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}
	
	public static Configuration getCfg() {
		return cfg;
	}
}
